//
//  MineMessageController.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/12.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit

class MineMessageController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
    var tableView:UITableView = UITableView.init()
    let cellId:String = "CELLID"
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.createTabaleView()
//        self.createNODataView()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.setNavi()
    }
}
extension MineMessageController{
    //MARK:设置导航栏选项
    func setNavi(){
        self.navigationItem.title = "消息中心"
        self.navigationController?.navigationBar.barTintColor = .red
        self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white]
        self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "", imagStr: "ic_back", fontSize: 14, target: self, action: #selector(leftBarButtonAction))
    }
    //MARK:LeftBarButtonAction
    func leftBarButtonAction(){
        self.navigationController!.popViewController(animated: true)
    }
    func createTabaleView(){
        self.view.addSubview(self.tableView)
        self.tableView.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.top.equalTo(0)
            make.bottom.equalTo(0)
        }
        self.tableView.delegate = self
        self.tableView.dataSource = self
        self.tableView.register(MineMessageCell.self , forCellReuseIdentifier: cellId)
    }
    //MARK: cretaeNODataView
    func createNODataView(){
        let bgView:UIImageView = UIImageView.init(image: UIImage.init(named: "wuxiaoxi"))
        self.view.addSubview(bgView)
        bgView.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.top.equalTo(0)
            make.bottom.equalTo(0)
            make.top.equalTo(0)
        }
        bgView.contentMode = .scaleToFill
    }
    //MARK:-TABLEVEWDELEGATE
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
    @objc(numberOfSectionsInTableView:) func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    @objc(tableView:cellForRowAtIndexPath:) func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: cellId)
        (cell as!MineMessageCell).titleLabel.text = "充值100元先送100元"
        (cell as!MineMessageCell).timeLabel.text = "2016-10-25"
        return cell!
    }
    @objc(tableView:heightForRowAtIndexPath:) func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 66
    }
}

